<?php

namespace app\model;

use app\BaseModel;

class UserCensusCountModel extends BaseModel
{
    protected $pk = "id";

    protected $name = "user_census_count";


    /**
     * 增加数据
     * @param $use_id
     * @param $field
     * @param $size
     * @return mixed
     * @author yuncran@126.com
     */
    public static function addUserCensusCountInc($use_id, $field, $size = 1)
    {
        if ('user_fans_count' == $field) {
            self::getModel()->where('user_id', self::$uid)->inc('user_follow_count', $size)->update();
        }
        return self::getModel()->where('user_id', $use_id)->inc($field, $size)->update();
    }

    /**减少数据
     * @param $use_id
     * @param $field
     * @param $size
     * @return mixed
     * @author yuncran@126.com
     */
    public static function minusUserCensusCountDec($use_id, $field, $size = 1)
    {
        if ('user_fans_count' == $field) {
            self::getModel()->where('user_id', self::$uid)->dec('user_follow_count', $size)->update();
        }
        return self::getModel()->where('user_id', $use_id)->dec($field, $size)->update();
    }


}